package com.sunwayworld.basemodule.basedata.batchtype.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.basedata.batchtype.dao.LimsBatchCategoryDao;
import com.sunwayworld.basemodule.basedata.batchtype.bean.LimsBatchCategoryBean;
import com.sunwayworld.basemodule.basedata.batchtype.service.LimsBatchCategoryService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsBatchCategoryServiceImpl implements LimsBatchCategoryService {

    @Autowired
    private LimsBatchCategoryDao limsBatchCategoryDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsBatchCategoryDao getDao() {
        return limsBatchCategoryDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsBatchCategoryBean limsBatchCategory = jsonWrapper.parseUnique(LimsBatchCategoryBean.class);
        limsBatchCategory.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsBatchCategory);
        return limsBatchCategory.getId();
    }

}
